package com.jcnet.bizaia.adapter;
import com.jcnet.bizaia.R;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MainMenuAdapter extends BaseAdapter {

	private Context context;
	public int count;

	private String []menuNames;

	private int [] menuImg ;


	public MainMenuAdapter(Context context) {
		super();
		this.context = context;

		menuNames = context.getResources().getStringArray(R.array.menu_array);
		//menuImg = context.getResources().getIntArray(R.array.menu_img_array);
		menuImg = new int[menuNames.length];
		
		menuImg[0] = R.drawable.menu_favourite;
		menuImg[1] = R.drawable.menu_add;
		menuImg[2] = R.drawable.menu_talk;
		menuImg[3] = R.drawable.menu_download;
		menuImg[4] = R.drawable.menu_settting;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		count = menuNames.length;
		return count;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if(convertView == null)
		{
			holder = new ViewHolder();
			convertView = View.inflate(context,R.layout.menu_item_lay, null);
			holder.titleTextView = (TextView)convertView.findViewById(R.id.menuTxt);
			holder.imageView = (ImageView)convertView.findViewById(R.id.menuImg);
			convertView.setTag(holder);
		}else
		{
			holder = (ViewHolder)convertView.getTag();

		}

		holder.titleTextView.setText(menuNames[position].toString());
		holder.imageView.setBackgroundResource(menuImg[position]);

		return convertView;
	}

	static class ViewHolder{
		TextView titleTextView;
		ImageView imageView;
	}
}
